package com.telaxo.shooter2012.gfx {
	import flash.display.MovieClip;
	import flash.display.Stage;
	import flash.events.Event;
	import flash.geom.ColorTransform;
	/**
	 * @author Jeremy
	 */

	

	public class LanceFlamme extends MovieClip
	{
		private var stageRef : Stage;
		private var vitesseLaser : Number =2;
		public var vx:Number;
		public var vy:Number;
		private var carpetColor : ColorTransform;
		[Embed(source ='swf/Smokepuff.swf')]
		private var lanceflamme:Class; 
		public function LanceFlamme(s : Stage, x : Number, y : Number) : void
		{
			carpetColor = new ColorTransform();
			stageRef = s;
			vx = 0;
			vy = 0;
			vy =Math.random() * 3 - 5;
			vx =Math.random() - Math.random();
			this.x =x;
			this.y = y;

			carpetColor.color = 0xFF0000;
			this.transform.colorTransform = carpetColor; 
		    var lanceflamme:MovieClip = new lanceflamme(); 
			addChild(lanceflamme);
			alpha = Math.random();
			vx = Math.random() - Math.random();
			vy = Math.random() * 3 - 5;
			scaleX = scaleY = Math.random();
			addEventListener(Event.ENTER_FRAME, loop, false, 0, true);
			
		}
		
		private function loop(e:Event) : void
		{
			alpha -= 0.008;
			y += vy;
			x += vx;
			scaleX = scaleY += 0.05;
			
		if (x > 520 || y > 420 || x < -20 || y < -20 || alpha <0) removeSelf();
		}
		
		public function degreesToRadians(degrees : Number) : Number {
			return degrees * Math.PI / 180;
		}
		
		private function removeSelf() : void
		{
			removeEventListener(Event.ENTER_FRAME, loop);
			parent.removeChild(this);
		}
	}
}
